#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <unistd.h>
#include <pthread.h>
#include <thread>


void* start(void* args)
{
    std::string name = static_cast<const char*>(args);
    while(true)
    {
        std::cout << "I am a new thread" << std::endl;
        sleep(1);
    }
    pthread_exit((void*)10);
}

int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,start,(void*)"thread-1");
    pthread_detach(tid);
    sleep(5);
    void* ret = nullptr;
    int n = pthread_join(tid,&ret);
    std::cout << "new thread exit code: " << (long long int)ret 
    << ",n: " << n << std::endl;
    return 0;//主线程return,表示进程结束
}
